﻿@model Wabo.Web.Areas.Manager.ViewModels.Log.LogListViewModel

@{
    ViewBag.Title = Messages.HeadingLogViewerList;
}
@using PagedList.Mvc; 
@using PagedList; 

<div class="page-header">
    <h1>@ViewBag.Title <a class="btn btn-danger pull-right" href="@Url.Action("Purge")">Purge</a></h1>
</div>
<div class="page-header">
<table>
    <tr>
        <td>
            @using (Html.BeginForm("Filter", "LogViewer", FormMethod.Post, new { @class = "form-inline" }))
            {
                @Html.LabelFor(m => m.FilterStartDate,new { @class = "control-label" })
                @:&nbsp;
                @Html.EditorFor(m => m.FilterStartDate)
                @Html.LabelFor( m => m.FilterEndDate,new { @class = "control-label" } )
                @:&nbsp;
                @Html.EditorFor( m=> m.FilterEndDate )
                @Html.LabelFor(m => m.FilterModule)
                @:&nbsp;
                @Html.DropDownListFor(m => m.FilterModule, Model.Modules)
                @:&nbsp;
                @Html.LabelFor( m => m.FilterUserId )
                @:&nbsp;
                @Html.DropDownListFor( m=>m.FilterUserId, Model.Users)
                <button class="pull-right btn btn-primary" type="submit">@Messages.LogFilterLabelButton</button>
            }
        </td>
    </tr>
</table>
</div>

<table class="table table-striped table-condensed">
     
    <thead>
        <tr>
            <th>@Messages.LogListTitleDate</th>
            <th>@Messages.LogListTitleOperation</th>
            <th>@Messages.LogListTitleUser</th>
            <th>@Messages.LogListTitleController</th>
            <th>@Messages.LogListTitleAction</th>
            <th>@Messages.LogListTitleDescription</th>
            
        </tr>
    </thead>
   
    @foreach( var logEntry in  ViewBag.CurrentLogItems)
    {
        <tr>
            <td>@logEntry.date</td>
            <td>@logEntry.LogOperationDescription</td>
            <td>@logEntry.User.name @logEntry.User.last_name</td>
            <td>@logEntry.module</td>
            <td>@logEntry.action</td>
            <td>@logEntry.description</td>
        </tr>
    }  
    
</table>
<div class="pagination-centered">
    @Html.PagedListPager( (IPagedList)ViewBag.CurrentLogItems, page => Url.Action("List", "LogViewer",new { id=page }) ,(PagedListRenderOptions)ViewBag.PagerRenderOptions)        
</div>
<br/>
<br/>